{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
<input type="hidden" name='message_id' id='message_id' value="{$info.message_id}" />
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">内容：</label>
						<div class="col-sm-9">
							<textarea id="content" name="content" disabled  class="form-control" placeholder="请输入内容">{$info.content}</textarea>
						</div>
					</div>
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['status'])){ $info['status'] = '0'; }; ?>
							<input name="status" value="0" type="radio" {if condition="$info.status eq '0'"}checked{/if} title="待审核">
							<input name="status" value="1" type="radio" {if condition="$info.status eq '1'"}checked{/if} title="通过">
							<input name="status" value="2" type="radio" {if condition="$info.status eq '2'"}checked{/if} title="拒绝">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">创建时间：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" value="{if condition="$info.createtime neq ''"}{$info.createtime|date='Y-m-d H:i:s'}{/if}" name="createtime"  placeholder="请输入创建时间" class="form-control" id="createtime" disabled>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">图片：</label>
						<div class="col-sm-6">
                            <ul>
                                <?php $imagesList = $info["images"];?>
                                {foreach name="imagesList" id="vo"}

                                <li style="float:left; margin-bottom:2px; margin-right:2px;"><a href="javascript:void(0)" onclick="openImg('{$vo}')"><img src="{$vo}" height="75"></a></li>
                                {/foreach}
                            </ul>
						</div>
					</div>
				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.update()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script src='__PUBLIC__/static/js/plugins/paixu/jquery-migrate-1.1.1.js'></script>
<script src='__PUBLIC__/static/js/plugins/paixu/jquery.dragsort-0.5.1.min.js'></script>
<script>
$(function(){
	$(".filelist").dragsort({dragSelector: "img",dragBetween: true ,dragEnd:function(){}});
});
layui.use(['form'],function(){});
uploader('images_upload','images','image',true,'{$info.images}','{:getUploadServerUrl()}');
setUploadButton('images_upload');
laydate.render({elem: '#createtime',type: 'datetime',trigger:'click'});
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('message_id').set('wxapp_id').set('content').set('createtime');
};

CodeInfoDlg.update = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }
	 var status = $("input[name = 'status']:checked").val();
	 var images = {};
	 $(".images li").each(function() {
		if($(this).find('img').attr('src')){
	 		images[$(this).index()] = {'url':$(this).find('img').attr('src'),'title':$(this).find('input').val()};
		}
	 });
	 var ajax = new $ax(Feng.ctxPath + "/ZhMessage/update", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	 ajax.set('status',status);
	 ajax.set('images',(JSON.stringify(images) == '{}' || JSON.stringify(images) == '{"":""}') ? '' : JSON.stringify(images));
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
